package com.xyulu.config.aop;

import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @Description TODO
 * @Author luming
 * @Date 2021/2/22
 * @Version 1.0
 */
@Aspect
@Component
public class LogAspect {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 定义切面
     */
    @Pointcut("execution(* com.xyulu.controller..*.*(..))")
    public void log() {
    }

    @Before("log()")
    public void doBefore() {

        logger.info("=========doBefore=======");
    }

    @After("log()")
    public void doAfter() {
        logger.info("=========doAfter=======");
    }

    @AfterReturning(returning = "result",pointcut = "log()")
    public void doAfterReturning(Object result) {
        logger.info("Return ------ {}",result );
    }
}
